<?php

namespace app\admin\model\user;

use think\Model;


class BrokerageLog extends Model
{

    

    

    // 表名
    protected $table = 'user_brokerage_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'mold_text',
        'mold2_text',
    ];
    

    
    public function getMoldList()
    {
        return ['order' => __('Mold order'), 'exchange' => __('Mold exchange')];
    }


    public function getMold2List()
    {
        return ['brokerage' => __('Mold2 brokerage'), 'score' => __('Mold2 score')];
    }


    public function getMoldTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['mold']) ? $data['mold'] : '');
        $list = $this->getMoldList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getMold2TextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['mold2']) ? $data['mold2'] : '');
        $list = $this->getMoldList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function fromusergroup(){
        return $this->belongsTo('app\admin\model\UserGroup','from_user_group_id','id');
    }


    public function fromuser(){
        return $this->belongsTo('app\admin\model\User','from_user_id','id');
    }


    public function tousergroup(){
        return $this->belongsTo('app\admin\model\UserGroup','to_user_group_id','id');
    }


    public function touser(){
        return $this->belongsTo('app\admin\model\User','to_user_id','id');
    }


    public function claimshop(){
//        return $this->belongsTo('app\admin\model\User','claim_shop_id','id');
        return $this->belongsTo('app\admin\model\Shop','claim_shop_id','id');
    }


    public function usercouponexchange(){
        return $this->belongsTo('app\admin\model\user\UserCouponExchange','user_coupon_exchange_id','id');
    }


    public function orderid(){
        return $this->belongsTo('app\admin\model\order\Order','order_id','id');
    }


}
